 <script type="text/javascript">
     $(function () {
        $('[data-toggle="tooltip"]').tooltip();
    });
        $("#importevent").bind("click",function(){
          $("#fileToUpload").click();
        });

        function fileSelected(fileToUpload) {
            var file = document.getElementById(fileToUpload).files[0];
            if (file) {
                $(".progress").show();
                var fd = new FormData();
                fd.append("fileToUpload", document.getElementById(fileToUpload).files[0]);
                fd.append("userid",{$user.id});
                var xhr = new XMLHttpRequest();
                xhr.upload.addEventListener("progress", uploadProgress, false);
                xhr.addEventListener("load", uploadComplete, false);
                xhr.addEventListener("error", uploadFailed, false);
                xhr.addEventListener("abort", uploadCanceled, false);
                xhr.open("POST", "__APP__/Event/importevent");//修改成自己的接口
                xhr.send(fd);
            }
        }

        function uploadProgress(evt) {
            if (evt.lengthComputable) {
                var percentComplete = Math.round(evt.loaded * 100 / evt.total);
                //document.getElementById('progressNumber').innerHTML = percentComplete.toString() + '%';
                $(".progress-bar").css("width",function(){return percentComplete.toString() + '%'});
                $(".progress-bar").text(percentComplete.toString() + '%');
            }else {
                document.getElementById('progressNumber').innerHTML = 'unable to compute';
            }
        }
            
        function uploadComplete(evt) {
            /* 服务器端返回响应时候触发event事件*/
            //alert(evt.target.responseText);
            var res= JSON.parse(evt.target.responseText);
            if(res.status==1){
                alert('导入成功');
                $(".progress").hide();
                var file = $("#fileToUpload") 
                file.after(file.clone().val("")); 
                file.remove();
                editurl('__APP__/Event/user/id/{$user.id}/pubtype/1');
            }else{
                alert(res.msg);
                var file = $("#fileToUpload") 
                file.after(file.clone().val("")); 
                file.remove();
            }
        }
        function uploadFailed(evt) {
            alert("There was an error attempting to upload the file.");
        }
        function uploadCanceled(evt) {
            alert("The upload has been canceled by the user or the browser dropped the connection.");
        }
 </script>

 <div class="row">
                <div class="col-lg-12">
                    <h3 class="page-header"><i class="fa fa-chevron-left" onclick="closeurl();"></i>用户活动管理</h3>
                </div>
                <!-- /.col-lg-12 -->
            </div>

            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-green">
                        <div class="panel-heading">
                            用户简介
                        </div>
                        <div class="panel-body">
                            <div class="media">
                              <div class="media-left">
                                <a href="#">
                                  <img class="media-object" src="<if condition="$user.image eq ''">{$user.headimgurl}<else />{$user.image}</if>" alt="用户头像" width="100">
                                </a>
                              </div>
                              <div class="media-body">
                                <h4 class="media-heading"><b>{$user.name}</b></h4>
                                <p>
                                {:L('hospital')}:{$user.hospital}
                                {:L('address')}:{$user.address}
                                </p>
                                <p>
                                {:L('department')}:{$user.department}
                                {:L('position')}:{$user.position}
                                {:L('socialposition')}:{$user.socialposition}
                                </p>
                                <p>
                                {:L('mobile')}:{$user.mobile}
                                {:L('email')}:{$user.email}
                                </p>
                              </div>
                            </div>  
                        </div>
                        <div class="panel-footer">
                            <button type="button" onclick = "editurl('__APP__/Event/user/id/{$userid}/pubtype/2');" class="btn btn-primary btn-sm">已发布活动</button>
                            <button type="button" onclick = "editurl('__APP__/Event/user/id/{$userid}/pubtype/1');" class="btn btn-info btn-sm">存草稿活动</button>
                            <button type="button" onclick = "editurl('__APP__/Event/user/id/{$userid}/pubtype/3');" class="btn btn-danger btn-sm">已屏蔽活动</button>
                            <button type="button" onclick = "editurl('__APP__/Event/user/id/{$userid}/pubtype/4');" class="btn btn-warning btn-sm">已参加的活动</button>
                            <button type="button" onclick = "editurl('__APP__/Event/user/id/{$userid}/pubtype/5');" class="btn btn-primary btn-sm">活动评论</button>
                            <button type="button" onclick = "editurl('__APP__/Event/user/id/{$userid}/pubtype/6');" class="btn btn-danger btn-sm">被屏蔽的评论</button>
                            <button type="button" onclick = "editurl('__APP__/Event/add/userid/{$userid}/pubtype/{$pubtype}/p/{$currentpage}');" class="btn btn-success btn-sm">添加新活动</button>
                            <button type="button" id="importevent" class="btn btn-warning btn-sm">导入活动</button>
                            <div class="progress" style="display:none;width:200px;margin-top:12px;">
                                <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
                                    0%
                                </div>
                            </div>                           
                        </div>
                    </div>
              
                </div>
                <div class="col-lg-12"> </div>   
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <if condition="$pubtype eq 1">存草稿活动列表<elseif condition="$pubtype eq 2" />已发布活动列表<elseif condition="$pubtype eq 3" />已屏蔽活动列表<elseif condition="$pubtype eq 4" />已参加的活动<elseif condition="$pubtype eq 5" />活动评论<else />被屏蔽的评论</if>
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                      <if condition="$pubtype lt 5">
                                        <tr>
                                            <th><center>{:L('isonline')}</center></th>
                                            <th><center>{:L('name')}</center></th>
                                            <th><center>{:L('price')}</center></th>
                                            <th><center>{:L('eventtime')}</center></th>
                                            <th><center>{:L('eventmember')}</center></th>
                                            <th><center>操作</center></th>
                                        </tr>
                                        <else />
                                        <tr>
                                            <th><center>参与评论的活动</center></th>
                                            <th><center>评论的内容</center></th>
                                            <if condition="$pubtype eq 5">
                                            <th><center>创建时间</center></th>
                                            <else />
                                            <th><center>屏蔽时间</center></th>
                                            </if>
                                            <th><center>操作</center></th>
                                        </tr>
                                        </if>
                                    </thead>
                                    <tbody>
                                        <if condition="$pubtype lt 5">
                                        <volist name="list" id="vo">
                                        <tr class="odd gradeX">
                                        <td style="vertical-align: middle;">
                                                <center>
                                                    <if condition="$vo.isonline eq 1">线上
                                                    <else />线下
                                                    </if>
                                                </center>
                                            </td>
                                            <td style="vertical-align: middle;"><center>{$vo['name']}</center></td>
                                            <td style="vertical-align: middle;"><center>{$vo.price}</center>
                                            </td>
                                            <td style="vertical-align: middle;"><center>{$vo['starttime']}-{$vo['endtime']}</center></td>
                                            <td class="center" style="vertical-align: middle;"><center>{$vo['membercount']-$vo['restnums']}/{$vo['membercount']}</center></td>
                                            <td class="center" style="vertical-align: middle;">
                                                <center>
                                                    <if condition="$pubtype eq 4">
                                                        <button type="button" class="btn btn-warning btn-xs" data-toggle="modal" data-target="#exampleModal" data-whatever="{$vo.id}" title="查看参加的活动">
                                                        <i class="glyphicon glyphicon-edit"></i>
                                                        </button>
                                                    <else />
                                                    <button type="button" class="btn btn-success btn-xs"  data-toggle="tooltip" data-placement="bottom" title="编辑用户活动" onclick="editurl('__APP__/Event/edit/id/{$vo.id}/userid/{$userid}/pubtype/{$pubtype}/p/{$currentpage}');">
                                                        <i class="fa fa-edit"></i>
                                                    </button>
                                                    </if>
                                                    <if condition="$pubtype eq 1">
                                                    <button type="button" class="btn btn-primary btn-xs"  data-toggle="tooltip" data-placement="bottom" title="发布用户活动" onclick="publish({$vo.id})">
                                                        <i class="fa fa-play"></i>
                                                    </button>
                                                    </if>
                                                    <if condition="$pubtype eq 2">
                                                    <button type="button" class="btn btn-info btn-xs"  data-toggle="tooltip" data-placement="bottom" title="用户活动存草稿" onclick="savetemp({$vo.id})">
                                                        <i class="fa fa-pause"></i>
                                                    </button>
                                                    </if>
                                                </center>
                                            </td> 
                                        </tr>
                                        </volist>
                                        <else />
                                        <volist name="list" id="vo">
                                        <tr class="odd gradeX">
                                            <td style="vertical-align: middle;"><center><button type="button" class="btn btn-warning btn-xs" data-toggle="modal" data-target="#exampleModal" data-whatever="{$vo.event_id}" title="查看评论的活动">
                                                        <i class="glyphicon glyphicon-edit"></i>
                                                    </button></center></td>
                                            <td style="vertical-align: middle;"><center>{$vo.content}</center>
                                            </td>
                                            <td style="vertical-align: middle;"><center><if condition="$pubtype eq 5">{$vo.addtime|date="Y-m-d H:i:s",###}<else />{$vo.masktime|date="Y-m-d H:i:s",###}</if></center></td>
                                            <td class="center" style="vertical-align: middle;">
                                                <center>
                                                  <button type="button"  title="编辑活动回复" class="btn btn-success btn-xs" data-toggle="modal" data-target="#editModal" data-whatever="{$vo.id}">
                                                        <i class="fa fa-edit"></i>
                                                    </button>
                                                </center>
                                            </td> 
                                        </tr>  
                                        </volist>
                                        </if>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            {$page}
        </div>

    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
                <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                  <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="exampleModalLabel">查看参加的活动</h4>
                      </div>
                      <div class="modal-body">
                        <div class="row">
                            <div class="col-md-12">
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('cashtype')}
                                  </div>
                                  <div class="panel-body cashtype">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('isonline')}
                                  </div>
                                  <div class="panel-body isonline">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('eventlink')}
                                  </div>
                                  <div class="panel-body eventlink">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('location')}
                                  </div>
                                  <div class="panel-body location">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('price')}
                                  </div>
                                  <div class="panel-body price">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('eventimage')}
                                  </div>
                                  <div class="panel-body eventimage">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('name')}
                                  </div>
                                  <div class="panel-body name">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('organizer')}
                                  </div>
                                  <div class="panel-body organizer">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('period')}
                                  </div>
                                  <div class="panel-body period">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('starttime')}
                                  </div>
                                  <div class="panel-body starttime">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('endtime')}
                                  </div>
                                  <div class="panel-body endtime">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('major')}
                                  </div>
                                  <div class="panel-body major">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('partitions')}
                                  </div>
                                  <div class="panel-body partitions">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('membercount')}
                                  </div>
                                  <div class="panel-body membercount">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('conditions')}
                                  </div>
                                  <div class="panel-body conditions">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('description')}
                                  </div>
                                  <div class="panel-body description">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>.
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('schedule')}
                                  </div>
                                  <div class="panel-body schedule">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('traffic')}
                                  </div>
                                  <div class="panel-body traffic">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('contact')}
                                  </div>
                                  <div class="panel-body contact">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('tips')}
                                  </div>
                                  <div class="panel-body tips">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                              <div class="panel panel-default">
                                  <div class="panel-heading">
                                      {:L('praise')}
                                  </div>
                                  <div class="panel-body praise">
                                      
                                  </div>
                                  <div class="panel-footer">
                                  </div>
                              </div>
                            </div>
                        </div>
                      </div>
                      <div class="modal-footer">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="editModalLabel">编辑回复</h4>
                      </div>
                      <div class="modal-body">
                        <form>
                          <div class="form-group">
                            <label for="content-name" class="control-label">编辑内容</label>
                            <textarea class="form-control" id="content-name" rows="10"></textarea>
                            <input type="hidden" name="editid">
                          </div>
                        </form>
                      </div>
                      <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" id="edit-submit" class="btn btn-primary">提交</button>
                      </div>
                    </div>
                  </div>
                </div>
                <script type="text/javascript">
                    $('#editModal').on('show.bs.modal', function (event) {
                      var button = $(event.relatedTarget) // Button that triggered the modal
                      var recipient = button.data('whatever') // Extract info from data-* attributes
                      // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
                      // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
                      var modal = $(this);
                      $.post("__APP__/Event/getcontent",{id:recipient},function(e){
                        modal.find('.modal-body textarea').val(e.content);
                        modal.find('.modal-body input').val(recipient);
                      })   
                    })

                    $("#edit-submit").on("click",function(){
                        var recipient=$('#editModal').find(".modal-body input").val();
                        var content = $('#editModal').find(".modal-body textarea").val();
                        $.post("__APP__/Event/postcontent",{id:recipient,content:content},function(e){
                            if(e.status==1){
                                $('#editModal').modal('hide');
                                editurl("__APP__/Event/user/id/{$userid}/pubtype/{$pubtype}/p/{$currentpage}");
                            }else{
                                alert("保存出错");
                            }
                        })
                    });
                    $('#exampleModal').on('show.bs.modal', function (event) {
                      var button = $(event.relatedTarget) // Button that triggered the modal
                      var recipient = button.data('whatever') // Extract info from data-* attributes
                      // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
                      // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
                      var modal = $(this);
                      modal.find('.modal-body .imageupload').html("");
                      $.post("__APP__/Event/getevent",{id:recipient},function(e){
                        if(e.list.cashtype==1){
                            modal.find('.modal-body .cashtype').html('免费'); 
                        }else{
                            modal.find('.modal-body .cashtype').html('收费'); 
                        }
                        if(e.list.isonline==1){
                            modal.find('.modal-body .isonline').html('线上'); 
                        }else{
                            modal.find('.modal-body .isonline').html('线下'); 
                        }
                        if(e.list.eventlink==0){
                            modal.find('.modal-body .eventlink').html('无'); 
                        }else{
                            modal.find('.modal-body .eventlink').html(e.list.eventlink); 
                        }
                        modal.find('.modal-body .location').html(e.list.location);
                        modal.find('.modal-body .price').html(e.list.price);
                        modal.find('.modal-body .name').html(e.list.name);
                        modal.find('.modal-body .period').html(e.list.period);
                        modal.find('.modal-body .starttime').html(e.list.starttime);
                        modal.find('.modal-body .endtime').html(e.list.endtime);
                        modal.find('.modal-body .major').html(e.list.major);
                        modal.find('.modal-body .partitions').html(e.list.partitions);
                        modal.find('.modal-body .membercount').html(e.list.membercount);
                        modal.find('.modal-body .conditions').html(e.list.conditions);
                        modal.find('.modal-body .description').html(e.list.description);
                        modal.find('.modal-body .schedule').html(e.list.schedule);
                        modal.find('.modal-body .traffic').html(e.list.traffic);
                        modal.find('.modal-body .tips').html(e.list.tips);
                        modal.find('.modal-body .praise').html(e.list.praise);
                        if(e.image){
                          $.each(e.image,function(k,v){
                            modal.find('.modal-body .eventimage').append("<img src='"+v.image+"' width='50' height='50'> ");
                          })
                        };
                        if(e.organizer){
                          $.each(e.organizer,function(k,v){
                            modal.find('.modal-body .organizer').append(v.name+"<br>");
                          })
                        };
                        if(e.contact){
                          $.each(e.contact,function(k,v){
                            modal.find('.modal-body .contact').append(v.name+" "+v.mobile+" "+v.email+"<br>");
                          })
                        };
                      })
                      
                    });

                    function publish(id){
                        $.post('__APP__/Event/publish',{id:id},function(data){
                            if(data.status==1){
                                alert('操作成功');
                                editurl('__APP__/Event/user/id/{$userid}/pubtype/2');
                            }else{
                                alert('操作失败');
                            }
                        });        
                    }
                     function savetemp(id){
                        $.post('__APP__/Event/savetemp',{id:id},function(data){
                            if(data.status==1){
                                alert('操作成功');
                                editurl('__APP__/Event/user/id/{$userid}/pubtype/1');
                            }else{
                                alert('操作失败');
                            }
                        });        
                    }   
    </script>

</body>

</html>
